package ui.listener;

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.IWorkbenchPage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ViewActivateEvent implements ISelectionChangedListener {
	
	public final static Logger logger = LoggerFactory.getLogger(ViewActivateEvent.class);
	private IWorkbenchPage page;
	private String refViewId;
	private String viewId;
	
	public ViewActivateEvent(IWorkbenchPage page, String refViewId){
		this.page = page;
		this.refViewId = refViewId;
		
	}
	public ViewActivateEvent(IWorkbenchPage page, String viewId, String refViewId){
		this.page = page;
		this.refViewId = refViewId;
		this.viewId = viewId;
	}
		
	@Override
	public void selectionChanged(SelectionChangedEvent event) {
		Object selection = ((IStructuredSelection)event.getSelection()).getFirstElement();
//		page.activate(page.findView(refViewId));
//		page.activate(page.findView(viewId));
		page.bringToTop(page.findView(refViewId));
		
	}

}
